<template>
  <el-card>
    <el-form inline :disabled="screen">
      <el-form-item label="一级分类">
        <el-select
          placeholder="请选择"
          v-model="categoryStore.mainCategoryId"
          @change="handle1"
        >
          <el-option
            :label="item.name"
            v-for="item in categoryStore.mainCategoryArr"
            :key="item.id"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select
          placeholder="请选择"
          @change="handle2"
          v-model="categoryStore.secCategoryId"
          :disabled="!categoryStore.mainCategoryId"
        >
          <el-option
            :label="item.name"
            v-for="item in categoryStore.secCategoryArr"
            :key="item.id"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select
          placeholder="请选择"
          v-model="categoryStore.thirdCategoryId"
          :disabled="!categoryStore.secCategoryId"
        >
          <el-option
            :label="item.name"
            v-for="item in categoryStore.thirdCategoryArr"
            :key="item.id"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup lang="ts" name="Category">
import useCategoryStore from '@/store/modules/category.ts'
import { onMounted } from 'vue'
let categoryStore = useCategoryStore()

onMounted(() => {
  categoryStore.getC1()
})

function handle1() {
  categoryStore.getC2()
}

function handle2() {
  categoryStore.getC3()
}

defineProps(['screen'])
</script>

<style scoped lang="scss">
.el-select {
  --el-select-width: 220px;
}
</style>
